public class Main {
    public static void main(String[] args) {


        Aggregate aggregate = new ConcreteAggregate();    //变化点，可以变化具体不同的聚合类对象
        //迭代器不要直接new,(!!有些类不让你new，而是通过别的类create)
        AbstractIterrator iterrator = aggregate.createIterator();

        iterrator.addObject("张三");
        iterrator.addObject("李四");
        iterrator.addObject("王五");

        while (iterrator.hasNext()) {
            System.out.println(iterrator.currentItem().toString());
            iterrator.moveNext();
        }
        System.out.println("=========================================");
        iterrator.removeObject("王五");
        iterrator.moveFirst();
        while (iterrator.hasNext()) {
            System.out.println(iterrator.currentItem().toString());
            iterrator.moveNext();
        }
    }
}